from django.db import models
from django.contrib.auth.models import AbstractUser
from django.contrib.auth.models import UserManager
from django.utils.translation import gettext_lazy as _
import uuid

# Create your models here.

class NewUser(AbstractUser):

    role_type = [
        [0, 'admin'],
        [1, 'user'],
    ]


    name = models.CharField(max_length=10, default='')
    roles = models.IntegerField(verbose_name='角色', choices=role_type, default=1)
    sex = models.CharField(max_length=10, default='', verbose_name='性别')
    last_login = models.DateTimeField(_('last login'), blank=True, null=True, auto_now=True)
    objects = UserManager()

    class Meta(AbstractUser.Meta):
        swappable = 'AUTH_USER_MODEL'
        pass


class Informations(models.Model):
    number = models.CharField(verbose_name='编号', max_length=20,default='#')
    shortage = models.CharField(verbose_name='重大缺陷', max_length=20)
    detail = models.CharField(verbose_name='具体情况', max_length=100)
    occure_time = models.CharField(verbose_name='发生时间', max_length=50)
    cause = models.CharField(verbose_name='产生原因', max_length=100)
    option = models.CharField(verbose_name="应对措施", max_length=50)
    person_responsibility = models.CharField(verbose_name="负责人", max_length=10)
    person_record = models.CharField(verbose_name="记录人", max_length=10)
    record_time = models.CharField(verbose_name="记录时间", max_length=50)
    condition = models.CharField(verbose_name="执行情况", max_length=50)
    is_delete = models.BooleanField(verbose_name='是否删除', default=False)
    class Meta:
        verbose_name_plural = '故障信息'

class Tasks(models.Model):


    number = models.CharField(verbose_name='编号', max_length=20)
    description = models.CharField(verbose_name='故障概要', max_length=50)
    person_record = models.CharField(verbose_name='登记人', max_length=20)
    person_finish = models.CharField(verbose_name='维修人', max_length=20, default='未修复')
    is_fix = models.BooleanField(verbose_name='是否修好', default=False)

    class Meta:
        verbose_name_plural = '维修信息'

class Shortages(models.Model):

    shortage = models.CharField(verbose_name='重大缺陷', max_length=50)
    count = models.IntegerField(verbose_name='故障个数', default=0)

    class Meta:
        verbose_name_plural = '缺陷信息'

class Machines(models.Model):

    machine = models.CharField(verbose_name='机组', max_length=50)
    count = models.IntegerField(verbose_name='故障个数', default=0)

    class Meta:
        verbose_name_plural = '机组信息'